//
//  status.swift
//  WeiBo09
//
//  Created by 裘明 on 15/9/10.
//  Copyright © 2015年 qm. All rights reserved.
//


import UIKit
/// 微博数据
class Status: NSObject {
    
    /// 微博创建时间
    var created_at: String?
    /// 微博ID
    var id:	NSInteger = 0
    /// 微博来源
    var source:	String?
    /// 微博信息内容
    var text: String?
    /// 用户模型 - 如果使用KVC会变成字典
    var user: User?
    /// 配图URL字符串的数组
    var pic_urls: [[String: String]]?
    /// 用户转发的微博
    var retweeted_status: Status?
    
    // MARK: - 构造函数
    /// 字典转模型
    init(dict: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }
    
    /// 将用户模型进行字典转模型
    override func setValue(value: AnyObject?, forKey key: String) {
    if key == "user" {
        user = User(dict: value as! [String: AnyObject])
        return
        }
        
    if key == "retweeted_status" {
        retweeted_status = Status(dict: value as! [String: AnyObject])
        return
    }
        
        super.setValue(value, forKey: key)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    
    override var description: String {
        let keys = ["created_at", "id", "source", "text", "pic_urls", "retweeted_status"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
    
    
}
